Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For some related fields, Django first does a select, then it probably loads each object into memory? But after that it does the deletion using a
INstatement with the ID of the objects...Using raw_delete avoids that, but it can also cause integrity problems, as Django does its own implementation of on_delete, so I chose models that don't have additional relations and also shouldn't have problems as they are always deleted when the project is deleted. Another source of problems is when models have foreign fields with on_delete=SET_NULL, as django will do an UPDATE over the model with all the related fields... for example for latest_build, django will run an update over all projects with an
IN (... all builds IDs..), to set the latest_build ID to null..., which is silly since the whole project model is being deleted, but django doesn't know that lates_build can only contain a build from the project. A raw delete could help, but builds and versions have a lot of related fields in other models, so I'm a little hesitant.Closes #12410
Ref #10040